package com.principle.prototype.deepclone;

public class Client {
    public static void main(String[] args) throws Exception {
        DeepProtoType p =new DeepProtoType();
        p.name="sj";
        p.deepCloneableTarget=new DeepCloneableTarget("大牛","牛的类");
        //方式1 完成深拷贝
        DeepProtoType clone =(DeepProtoType) p.clone();
        System.out.println("p:"+p.toString()+",p.deepCloneableTarget:"+p.deepCloneableTarget.hashCode());
        System.out.println("clone:"+p.toString()+",clone.deepCloneableTarget:"+clone.deepCloneableTarget.hashCode());

        //方式2
        DeepProtoType o =(DeepProtoType) p.deepClone();
        System.out.println("p:"+p.toString()+",p.deepCloneableTarget:"+p.deepCloneableTarget.hashCode());
        System.out.println("o:"+p.toString()+",o.deepCloneableTarget:"+o.deepCloneableTarget.hashCode());

    }
}
